package com.testspring;

import com.handspring.ZhengApplicationContext;
import com.testspring.service.OrderService;
import com.testspring.service.UserInterface;
import com.testspring.service.UserService;

/**
 * @author: ztl
 * @date: 2024/04/17 22:24
 * @desc:
 */
public class test {

    public static void main(String[] args) {

        // 这一步我们都需要做哪些事：
        // 1、扫描指定路径(TestApp的@Mycmponent的路径)
        // 2、创建非懒加载的单例bean，
        ZhengApplicationContext applicationContext = new ZhengApplicationContext(TestApp.class);

        UserInterface userService = (UserInterface) applicationContext.getBean("userServiceAop");
        // 一旦调用了test方法，就会走到com.testspring.service.ZtlMyBeanPostProcessor.postProcessBeforeInitialization的invoke方法中去
        userService.test();
        // 因为是单例，所以多次拿是同一个对象
//        System.out.println(applicationContext.getBean("userService"));
//        System.out.println(applicationContext.getBean("userService"));
//        System.out.println(applicationContext.getBean("userService"));

        // 测试一下，orderService不加@MyComponent或者@MyComponent的括号里面没加类
//        OrderService orderService = (OrderService) applicationContext.getBean("orderService");
//        System.out.println(orderService);
    }
}
